var express = require('express');
var router = express.Router();
let { uploadFiles } = require('../util/handleFile')
router.post('/img', (req, res) => {
    let uploadMethod = uploadFiles({
        path: './public/images',
        key: 'file',
        size: 1024000
    })
    console.log('v1')
    console.log('v2')
    uploadMethod(req, res, (err) => {
        console.log(req.files);
        if (err) {
            res.send({
                message: '上传失败'
            })
        } else {
            res.send({
                message: '上传成功',
                data: '/images/' + req.files[0].filename
            })
        }
    })
})

module.exports = router;